package com.cmxh.cloundnote.service;

import com.cmxh.cloundnote.mapper.CategoryMapper;
import com.cmxh.cloundnote.pojo.Category;
import com.cmxh.cloundnote.util.PageUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceimpl implements CategoryService{
@Autowired
    private CategoryMapper categoryMapper;
    @Override
    public PageInfo<Category> findAll(PageUtil pageUtil) {
        PageHelper.startPage(pageUtil.getPageNum(),pageUtil.getPageSize());
        Integer id = (Integer) pageUtil.getXx();
        List<Category> list = categoryMapper.findAll(id);
        PageInfo<Category> xx = new PageInfo<>(list);
        return xx;
    }

    @Override
    public int addCategory(Category category) {
      return categoryMapper.addCategory(category);
    }

    @Override
    public int deleted(Integer id) {
        return  categoryMapper.deleted(id);
    }

    @Override
    public int updateCategory(Category category) {
        return  categoryMapper.updateCategory(category);
    }

    @Override
    public List<Category> findById2(Integer id) {
        return categoryMapper.findById2(id) ;
    }
}
